@extends('admin.common.main')
@section('css')
    <!--引入CSS-->
    <link rel="stylesheet" type="text/css" href="/webuploader/webuploader.css">
@endsection
@section('content')
    <body>
    <article class="page-container">
        <form action="{{route('admin.article.store')}}" method="post" class="form form-horizontal" id="form-member-add">
            @include('admin.common.error')

            @csrf
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>文章标题：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" id="title" name="title">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>文章描述：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" id="desn" name="desn">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>文章封面图：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <div id="picker">选择文件
                    </div>
                    <img src="" id="img" alt="" width="100" height="100" hidden>
                    <input type="hidden" value="" name="pic" id="pic">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>文章作者：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" id="author" name="author">
                </div>
            </div>


            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>文章内容：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <textarea name="body" id="body" cols="30" rows="10"></textarea>
                </div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
    @endsection

    @section('js')
        <script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
        <!-- 编辑器源码文件 -->
        <script type="text/javascript" src="/ueditor/ueditor.all.js"></script>

        <script type="text/javascript" src="/webuploader/webuploader.js"></script>
        <!-- 实例化编辑器 -->
        <script type="text/javascript">
            var ue = UE.getEditor('body');

            var uploader = WebUploader.create({

                // swf文件路径
                swf: '/webuploader/Uploader.swf',
                method: 'post',
                auto: true,
                formData: {
                    _token: "{{csrf_token()}}"
                },
                server: "{{route('admin.article.local_upfile')}}",

                pick: '#picker',

                resize: false,
            });

            uploader.on( 'uploadSuccess', function( pic ,ret) {
                console.log(ret);
                $( '#img' ).show().attr('src',ret.data.pic);
                $( '#pic' ).val(ret.data.pic);
            });

        </script>
@endsection
